# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Daniel Micay <danielmicay@gmail.com>

pkgname=python-pygit2
pkgver=1.12.0
pkgrel=2
pkgdesc='Python bindings for libgit2'
arch=('loong64' 'x86_64')
url="https://github.com/libgit2/pygit2"
license=('GPL2')
depends=('libgit2.so' 'python-cffi' 'python-six' 'python-cached-property')
makedepends=('cython' 'python-build' 'python-cffi' 'python-installer' 'python-setuptools' 'git' 'python-six' 'python-wheel')
checkdepends=('python-pytest-runner')
source=("$url/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('014b635dbf017542d83f72d459ce835ea9713fe401986f428febfd317088c34f')

prepare() {
	cd "pygit2-$pkgver"
	# Disable tests that do stuff online
	sed -e '/has_network/s/True/False/' -i test/utils.py
}

build() {
	cd "pygit2-$pkgver"
	python -m build -wn
}

check() {
	cd "pygit2-$pkgver"
	local _pyver=cpython-$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
	PYTHONPATH="$PWD/build/lib.linux-$CARCH-$_pyver" pytest
}

package() {
	cd "pygit2-$pkgver"
	LANG=en_US.UTF8 python -m installer -d "${pkgdir}" dist/*.whl
}
